#!/bin/bash
err() { echo Error. $@ not found.; exit 1; }

cp deploydataflash.tcl /opt/armgcc/deploy
cd /opt/armgcc/deploy

[ -z `which sam-ba` ] && err sam-ba
[ ! -c /dev/ttyUSB0 ] && err /dev/ttyUSB0
[ ! -f deploydataflash.tcl ] && err deploydataflash.tcl
[ ! -f dataflash_at91sam9263ek.bin ] && err dataflash_at91sam9263ek.bin
[ ! -f u-boot.bin ] && err u-boot.bin
[ ! -f uImage.bin ] && err uImage.bin

sam-ba /dev/ttyUSB0 AT91SAM9263-EK deploy-dataflash
rm u-boot.env -f
